package com.vinder.api.config;

import io.swagger.annotations.Api;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


@Configuration //标记这是一个配置
@EnableSwagger2 //启用Swagger
public class SwaggerConfig {
    //创建接口文档信息
    public ApiInfo createApiInfo() {
        return new ApiInfoBuilder().title("vinder的接口文档").description("交友网站~").
                contact(new Contact("赵飞", "nothing to say", "snzcl@aliyun.com")).
                version("V1.0.0").build();
    }

    @Bean //IOC容器 存储  <bean>
    public Docket createApi() {
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(createApiInfo()).select().
                apis(RequestHandlerSelectors.withClassAnnotation(Api.class)).
                build();
    }
}
